
package org.apache.solr.response.transform;

import org.apache.solr.common.params.ShardParams;
import org.apache.solr.common.params.SolrParams;
import org.apache.solr.request.SolrQueryRequest;

/**
 * @since solr 4.0
 */
public class ShardAugmenterFactory extends TransformerFactory {

    @Override
    public DocTransformer create(String field, SolrParams params, SolrQueryRequest req) {

        String v = req.getParams().get(ShardParams.SHARD_URL);
        if(v == null) {
            if(req.getParams().getBool(ShardParams.IS_SHARD, false)) {
                v = "[unknown]";
            }
            else {
                v = "[not a shard request]";
            }
        }
        return new ValueAugmenter(field, v);
    }
}
